<?php

namespace App\Http\Controllers\home;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
class IndexController extends Controller
{

	// 首页 界面
    public function Index(){
    // 网站开关
       $web = DB::table('webconfig')-> first();
        $status = $web['status'];
        session(['web'=>$status]);
    
       if(session('web') == 2){
        // 关闭状态
        $webconfig = DB::table('webconfig') -> first();
        return view('home/webconfig/index',['webconfig'=> $webconfig]);
       }else{
            //前台公共模板下的友情链接 把友情链接表中的数据遍历存到session中
        $flink1 = DB::table('flink')-> where('where','1')-> where('status','1')-> get();
        $flink2 = DB::table('flink')-> where('where','2')-> where('status','1')-> get();
        $flink3 = DB::table('flink')-> where('where','3')-> where('status','1')-> get();
        $flink4 = DB::table('flink')-> where('where','4')-> where('status','1')-> get();
        
        //dd($flink);
        session(['flink1'=>$flink1]);
        session(['flink2'=>$flink2]);
        session(['flink3'=>$flink3]);
        session(['flink4'=>$flink4]);
            // 轮播图
        $data = DB::table('pic') -> get();
       
        // 首页图片
        $photo = DB::table('photo') -> where('cate','1') -> get();
        // dd($photo[0]);
        return view('home/index',['data'=>$data,'photo0'=>$photo[0],'photo1'=>$photo['1'],'photo2'=>$photo['2']]);
       }
    
    }
}
